<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/layouts/template.xhtml">
	<ui:define name="body">
		<h:form id="form" acceptcharset="ISO-8859-1">
			<p:panel header="#{msgs['massai.association.header.consult']}">

				<h:panelGrid style="width: 100%;">
					<p:commandButton value="#{msgs['common.register']}" action="associationRegister" 
						ajax="false" immediate="true" styleClass="buttonNew" tabindex="1"
						rendered="#{sessionBean.showAction('adminAssociation', 'insert')}" />
				</h:panelGrid>

				<fieldset>
					<legend><h:outputText value="#{msgs['common.search.filter']}" /></legend>

					<h:panelGrid columns="2">
						<h:panelGrid>
							<p:outputLabel value="#{msgs['massai.association.name']}" for="name" />
							<p:inputText id="name" tabindex="2" value="#{associationBean.department.alternativeName}" 
								style="width: 350px;" maxlength="150" />
						</h:panelGrid>

						<h:panelGrid>
							<p:outputLabel value="#{msgs['massai.association.status']}" for="status" />
							<p:selectOneMenu id="status" value="#{associationBean.department.status}" style="width: 160px;" tabindex="3">
								<f:selectItems value="#{associationBean.listStatus()}" />
							</p:selectOneMenu>
						</h:panelGrid>
					</h:panelGrid>

					<h:panelGrid>
						<p:commandButton tabindex="4" value="#{msgs['common.search']}" 
							ajax="true" actionListener="#{associationBean.find()}" update="form"
							rendered="#{sessionBean.showAction('adminAssociation', 'search')}" />
					</h:panelGrid>
				</fieldset>

				<p:spacer height="20px" />

				<p:dataTable var="ass" value="#{associationBean.dataModel}" rows="10" paginator="true" paginatorPosition="bottom"
					paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
					currentPageReportTemplate="{currentPage} de {totalPages}" rowsPerPageTemplate="5,10,20"
					id="dataTable" lazy="true" rowIndexVar="rowIndex" emptyMessage="#{msgs['common.no.record.found']}">
					<f:facet name="header"><p:outputLabel value="#{msgs['massai.association.collaboratorList']}" /></f:facet>

					<p:column headerText="#{msgs['massai.association.code']}" sortBy="#{ass.codeEmp}" width="80">
                        <h:outputText value="#{associationBean.completedZerosLeft(ass.codeEmp, 4)}" />
                    </p:column>

                    <p:column headerText="#{msgs['massai.association.codeDepart']}" sortBy="#{ass.codeDepartment}" width="135">
                        <h:outputText value="#{ass.codeDepartment}" />
                    </p:column>

                    <p:column headerText="#{msgs['massai.association.codeSienge']}" sortBy="#{ass.codeSienge}" width="110">
                        <h:outputText value="#{ass.codeSienge}" />
                    </p:column>

                    <p:column headerText="#{msgs['massai.association.name']}" sortBy="#{ass.alternativeName}">
                        <h:outputText value="#{ass.alternativeName}" />
                    </p:column>

                    <p:column headerText="#{msgs['massai.association.status']}" sortBy="#{ass.status}" width="80">
                        <h:outputText value="#{ass.status.description}" />
                    </p:column>

                    <p:column headerText="#{msgs['common.delete']}" width="60" style="text-align: center;" 
                    	rendered="#{sessionBean.showAction('adminAssociation', 'delete')}">
						<h:commandLink id="delete"
							onclick="if (!window.confirm('Deseja excluir esse registro?') ) {return false}" 
			            	actionListener="#{associationBean.delete(ass)}">
							<img src="#{facesContext.externalContext.requestContextPath}/images/ico_remove.png" 
								width="16" height="16" border="0" name="#{msgs['common.delete']}" 
								alt="#{msgs['common.delete']}" id="icoRemove"
								title="#{msgs['common.delete']}" />
						</h:commandLink>
					</p:column>

					<p:column headerText="#{msgs['common.update']}" width="32" style="text-align: center;"
						rendered="#{sessionBean.showAction('adminAssociation', 'update')}">
						<h:link outcome="associationRegister" tabindex="5">
							<img src="#{facesContext.externalContext.requestContextPath}/images/ico_edit.png" 
								width="16" height="16" border="0" name="#{msgs['common.update']}" 
								title="#{msgs['common.update']}" alt="#{msgs['common.update']}" id="icoEdit" />
							<f:param name="param" value="#{ass.id}" />
						</h:link>
					</p:column>
                </p:dataTable>
			</p:panel>
		</h:form>
	</ui:define>
</ui:composition>
</html>